# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.4.1)

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.

include_directories(cosip/libosip/jni/include
                    cosip/libexosip/jni/include)
add_definitions(
        #-DHAVE_FCNTL_H
        -DHAVE_TIME_H
        #-DHAVE_SYS_SELECT_H
        #-DENABLE_TRACE
        -DHAVE_ARPA_INET_H
        -DHAVE_NETDB_H

        -DHAVE_FCNTL_H
        -DHAVE_SYS_TIME_H
        -DHAVE_STRUCT_TIMEVAL
        -DHAVE_SYS_SELECT_H
        -DHAVE_PTHREAD
        -DHAVE_SEMAPHORE_H
        -DENABLE_TRACE
        #-DOSIP_MONOTHREAD
)
add_library( # Sets the name of the library.
        cosdkjni

        # Sets the library as a shared library.
        SHARED

        # Provides a relative path to your source file(s).
        cosip/libosip/jni/src/osipparser2/osip_accept.c
        cosip/libosip/jni/src/osipparser2/osip_proxy_authenticate.c
        cosip/libosip/jni/src/osipparser2/osip_parser_cfg.c
        cosip/libosip/jni/src/osipparser2/osip_mime_version.c
        cosip/libosip/jni/src/osipparser2/osip_uri.c
        cosip/libosip/jni/src/osipparser2/osip_call_id.c
        cosip/libosip/jni/src/osipparser2/osip_contact.c
        cosip/libosip/jni/src/osipparser2/osip_header.c
        cosip/libosip/jni/src/osipparser2/osip_list.c
        cosip/libosip/jni/src/osipparser2/osip_authentication_info.c
        cosip/libosip/jni/src/osipparser2/osip_cseq.c
        cosip/libosip/jni/src/osipparser2/osip_message.c
        cosip/libosip/jni/src/osipparser2/osip_record_route.c
        cosip/libosip/jni/src/osipparser2/osip_authorization.c
        cosip/libosip/jni/src/osipparser2/sdp_accessor.c
        cosip/libosip/jni/src/osipparser2/osip_accept_language.c
        cosip/libosip/jni/src/osipparser2/osip_via.c
        cosip/libosip/jni/src/osipparser2/osip_allow.c
        cosip/libosip/jni/src/osipparser2/osip_call_info.c
        cosip/libosip/jni/src/osipparser2/osip_proxy_authentication_info.c
        cosip/libosip/jni/src/osipparser2/osip_proxy_authorization.c
        cosip/libosip/jni/src/osipparser2/sdp_message.c
        cosip/libosip/jni/src/osipparser2/osip_accept_encoding.c
        cosip/libosip/jni/src/osipparser2/osip_content_encoding.c
        cosip/libosip/jni/src/osipparser2/osip_to.c
        cosip/libosip/jni/src/osipparser2/osip_content_disposition.c
        cosip/libosip/jni/src/osipparser2/osip_message_to_str.c
        cosip/libosip/jni/src/osipparser2/osip_www_authenticate.c
        cosip/libosip/jni/src/osipparser2/osip_error_info.c
        cosip/libosip/jni/src/osipparser2/osip_body.c
        cosip/libosip/jni/src/osipparser2/osip_content_length.c
        cosip/libosip/jni/src/osipparser2/osip_from.c
        cosip/libosip/jni/src/osipparser2/osip_alert_info.c
        cosip/libosip/jni/src/osipparser2/osip_message_parse.c
        cosip/libosip/jni/src/osipparser2/osip_content_type.c
        cosip/libosip/jni/src/osipparser2/osip_port.c
        cosip/libosip/jni/src/osipparser2/osip_md5c.c
        cosip/libosip/jni/src/osipparser2/osip_route.c
        cosip/libosip/jni/src/osip2/osip_transaction.c
        cosip/libosip/jni/src/osip2/osip_dialog.c
        cosip/libosip/jni/src/osip2/osip_event.c
        cosip/libosip/jni/src/osip2/nict_fsm.c
        cosip/libosip/jni/src/osip2/port_thread.c
        cosip/libosip/jni/src/osip2/nict.c
        cosip/libosip/jni/src/osip2/nist.c
        cosip/libosip/jni/src/osip2/port_sema.c
        cosip/libosip/jni/src/osip2/ict_fsm.c
        cosip/libosip/jni/src/osip2/ict.c
        cosip/libosip/jni/src/osip2/port_fifo.c
        cosip/libosip/jni/src/osip2/ist_fsm.c
        cosip/libosip/jni/src/osip2/ist.c
        cosip/libosip/jni/src/osip2/osip_time.c
        cosip/libosip/jni/src/osip2/port_condv.c
        cosip/libosip/jni/src/osip2/fsm_misc.c
        cosip/libosip/jni/src/osip2/osip.c
        cosip/libosip/jni/src/osip2/nist_fsm.c

        cosip/libexosip/jni/tools/sip_reg.c
        cosip/libexosip/jni/src/eXsubscription_api.c
        cosip/libexosip/jni/src/eXregister_api.c
        cosip/libexosip/jni/src/jevents.c
        cosip/libexosip/jni/src/jcallback.c
        cosip/libexosip/jni/src/eXtl_tcp.c
        cosip/libexosip/jni/src/rijndael.c
        cosip/libexosip/jni/src/jreg.c
        cosip/libexosip/jni/src/sdp_offans.c
        cosip/libexosip/jni/src/eXconf.c
        cosip/libexosip/jni/src/jauth.c
        cosip/libexosip/jni/src/udp.c
        cosip/libexosip/jni/src/eXcall_api.c
        cosip/libexosip/jni/src/eXtl_tls.c
        cosip/libexosip/jni/src/jdialog.c
        cosip/libexosip/jni/src/eXtransport.c
        cosip/libexosip/jni/src/eXosip.c
        cosip/libexosip/jni/src/jrequest.c
        cosip/libexosip/jni/src/jsubscribe.c
        cosip/libexosip/jni/src/eXtl_dtls.c
        cosip/libexosip/jni/src/jcall.c
        cosip/libexosip/jni/src/misc.c
        cosip/libexosip/jni/src/milenage.c
        cosip/libexosip/jni/src/jresponse.c
        cosip/libexosip/jni/src/eXmessage_api.c
        cosip/libexosip/jni/src/eXtl_udp.c
        cosip/libexosip/jni/src/eXoptions_api.c
        cosip/libexosip/jni/src/eXinsubscription_api.c
        cosip/libexosip/jni/src/eXutils.c
        cosip/libexosip/jni/src/jpipe.c
        cosip/libexosip/jni/src/jpublish.c
        cosip/libexosip/jni/src/eXpublish_api.c
        cosip/libexosip/jni/src/jnotify.c
        cosip/libexosip/jni/src/inet_ntop.c

        cosdkmock/ua_webrtc_mock.cpp
        cosdkmock/uac.cpp
        cosdkmock/uac_jni.c)

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.

find_library( # Sets the name of the path variable.
        log-lib

        # Specifies the name of the NDK library that
        # you want CMake to locate.
        log)

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.

target_link_libraries( # Specifies the target library.
        cosdkjni

        # Links the target library to the log library
        # included in the NDK.
        ${log-lib})